package com.cxh.rmsq.ui.adapter.self

import android.content.Intent
import android.graphics.Color
import android.graphics.Typeface
import android.util.TypedValue
import android.view.View
import android.widget.ImageView
import android.widget.TextView
import androidx.core.view.isVisible
import com.blankj.utilcode.util.TimeUtils
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.module.LoadMoreModule
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.cxh.rmsq.R
import com.cxh.rmsq.common.IntentExtra
import com.cxh.rmsq.db.model.CommunityContent
import com.cxh.rmsq.db.model.FindProductBean
import com.cxh.rmsq.db.model.VipPrivilegesBean
import com.cxh.rmsq.ui.activity.self.CommentDetailActivity
import com.cxh.rmsq.ui.activity.self.LookUserDetailActivity2
import com.cxh.rmsq.ui.widget.SelectableRoundedImageView
import com.cxh.rmsq.utils.formatPrice
import com.cxh.rmsq.utils.loadImage
import com.hjq.shape.layout.ShapeLinearLayout


/**
 *
 */
class VipProductListAdapter() :
    BaseQuickAdapter<FindProductBean, BaseViewHolder>(R.layout.item_vip_product_list),
    LoadMoreModule {
    private var selectPos = 0

    fun getSelectPos(): Int {
        return selectPos
    }

    fun setSelectPos(selectPos: Int) {
        this.selectPos = selectPos
    }

    override fun convert(holder: BaseViewHolder, item: FindProductBean) {
        with(holder) {

            setText(R.id.tv_old_price, "原价￥" + formatPrice(item.originalPrice))
            setText(R.id.tv_vip_name, item.productName)
            setText(R.id.tv_price, formatPrice(item.actualPrice))

            if (selectPos == holder.layoutPosition) {
                holder.setTextColor(R.id.tv_vip_name, Color.parseColor("#ED7A28"))
                holder.setTextColor(R.id.tv, Color.parseColor("#ED7A28"))
                holder.setTextColor(R.id.tv_price, Color.parseColor("#ED7A28"))
                (holder.getView<View>(R.id.iv_top) as ImageView).setImageResource(R.mipmap.icon_openvip_sel)
                (holder.getView<View>(R.id.sll) as ShapeLinearLayout).shapeDrawableBuilder.setSolidColor(
                    Color.parseColor("#FCF2E9")
                )
                    .setStrokeColor(Color.parseColor("#ED7A28")).intoBackground()
            } else {
                holder.setTextColor(R.id.tv_vip_name, Color.parseColor("#9D9D9D"))
                holder.setTextColor(R.id.tv, Color.parseColor("#9D9D9D"))
                holder.setTextColor(R.id.tv_price, Color.parseColor("#9D9D9D"))
                (holder.getView<View>(R.id.iv_top) as ImageView).setImageResource(R.mipmap.icon_openvip_unsel)
                (holder.getView<View>(R.id.sll) as ShapeLinearLayout).shapeDrawableBuilder.setSolidColor(
                    Color.parseColor("#ffffff")
                )
                    .setStrokeColor(Color.parseColor("#CCCCCC")).intoBackground()
            }
        }
    }

}